package initialize

import (
	"fmt"
	_ "github.com/mbobakov/grpc-consul-resolver"
	"go.uber.org/zap"
	"google.golang.org/grpc"
	"order_api/global"
	"order_api/order"
)

func InitSrvConn() {
	Conn, err := grpc.Dial(
		fmt.Sprintf("consul://%s:%d/%s?wait=14s", global.AppConf.ConsulConfig.Host, global.AppConf.ConsulConfig.Port, "order_srv"),
		grpc.WithInsecure(),
		grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin"}`),
	)
	if err != nil {
		zap.S().Panic(err)
	}
	global.OrderService = order.NewOrderClient(Conn)
}
